package cn.demoxy.base;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @auther demo
 * @date 2022/5/16 23:08
 * 封装常用的查询参数以及分页
 */
@Data
public class BaseQuery<T extends BaseEntity> implements Serializable {
    /**
     * 关键词
     */
    @ApiModelProperty(value = "关键词")
    private String keyword;

    /**
     * 开始日期
     */
    @ApiModelProperty(value = "开始日期", hidden = true)
    private String startDate;

    /**
     * 结束日期
     */
    @ApiModelProperty(value = "结束日期", hidden = true)
    private String endDate;

    /**
     * 排序属性
     */
    @ApiModelProperty(value = "排序属性", hidden = true)
    private String prop;

    /**
     * 排序方式：asc,desc
     */
    @ApiModelProperty(value = "排序方式", hidden = true)
    private String order;

    /**
     * 当前页
     */
    @ApiModelProperty(value = "当前页")
    private int current = 0;

    /**
     * 每页的数量
     */
    @ApiModelProperty(value = "每页的数量")
    private int size = 50;

    /**
     * mybatis-plus分页对象
     *
     * @return
     */
    public IPage<T> page() {
        IPage<T> page = new Page<T>(this.current, this.size);
        return page;
    }
}